{% extends "views/homeIndex.html" %}
{% block right %}
用户管理

<div id="searchUser">
    <form action="/searchUser" method="post" id="searchinfo">
    <label>姓名：</label>
    <input type="text" name="username">
    <label>手机号：</label>
    <input type="text" name="phone">
    <label>角色：</label>
    <select name="roleid">
        <option value="">请选择角色</option>
        {% for role in seachUserData.roles%}
        <option value="{{role.id}}">{{role.rolename}}</option>
        {%endfor%}
    </select>
    <input type="button" value="搜索" onclick="submitSearch();">
    <input type="button" value="新增用户" onClick="location.href='/addUser'">
    </form>
</div>

<div>
    <table>
        <thead>

        </thead>
        <tbody>
            <tr>
                <td>{{user.username}}</td>
                <td>{{user.phone}}</td>
                <td>{{user.role.rolename}}</td>
                <td>
                    <input type="button" value="重置密码" onclick="defaultPassword('{{user.id}}')">
                    <input type="button" value="修改" onclick="updateUser('{{user.id}}')">
                    <input type="button" value="删除" onclick="deleteUser('{{user.id}}')">
                </td>
            </tr>
        </tbody>
    </table>
    
</div>
<script>
    function validate(info){
        if (confirm(info)){
            return ture;
        }else{
            return false;
        }
    }
    function submitSearch(){
        document.getElementById("searchInfo").submit();
    }
    function defaultPassword(userid){
        if(validate("确定要重置为默认密码吗？")){
            window.location.href="/users/defaultUserPass?id=" + userid
        }
    function deleteUser(userid){
        if(validate("确定要删除吗？")){
            
        }
    }
    }
</script>


{% endblock %}